from rest_framework.viewsets import ModelViewSet
from goods.models import SPUSpecification, SpecificationOption
from meiduo_admin.my_paginate import MyPageNumberPagination
from meiduo_admin.spu import spu_specs_serializers

# 获取spu的specs的信息
class SPUspecsViewSet(ModelViewSet): #涉及增删改查，要继承视图集，视图集要自动生成路由，且直接继承视图集即可
    pagination_class = MyPageNumberPagination
    serializer_class = spu_specs_serializers.SPUspecsViewSerializer
    queryset = SPUSpecification.objects.all()

# 获取specs的option的信息
class SpecsOptionViewSet(ModelViewSet): #涉及增删改查，要继承视图集，视图集要自动生成路由，且直接继承视图集即可
    pagination_class = MyPageNumberPagination
    serializer_class = spu_specs_serializers.SpecsOptionViewSerializer
    queryset = SpecificationOption.objects.all()